<?php

class MaskHelper extends AppHelper {

	var $helpers = array('JavaScript');
	
	/**
	 * add
	 * $this->Javascript->link($fn_jquery)
	 * $this->Javascript->link($fn_jquery_mask)
	 */
	function jsLoadMask($masks =array(),$options = array()) {
		ob_start();
		?>
		<script type="text/javascript" >
  	  		$.mask.options.attr = 'mask';		
			(function($){
			// call setMask function on the document.ready event
				$(function(){
					$('input:text').setMask();
				});
			})(jQuery);
		<?php foreach($masks as $name => $value):?>
			$.mask.masks.<?= $name ?> = {mask: '<?= $value ?>'};
		<?php endforeach; ?>
		<?php if(!empty($options)): ?>
			<?php foreach($options as $name => $value):?>				
				$.mask.options.<?= $name ?> = <?= $value ?>;
			<?php endforeach; ?>
		<?php endif; ?>
		</script>
		<?
		$str = ob_get_contents();
		ob_end_clean();
		return $str;
	}
	

}

?>